
function red() {
    console.log('red');
}
function green() {
    console.log('green');
}
function yellow() {
    console.log('yellow');
}

const light =  function (fn,time){
    fn()
    return new Promise((resolve,reject)=>{
        setTimeout(()=>{
            resolve()
        },time)
    })
}

function Circulation(){
    Promise.resolve().then(()=>{
        return light(red,3000)
    })
    .then(()=>{
        return light(green,2000)
    }).then(()=>{
        return light(yellow,1000)
    }).then(()=>{
        return Circulation()
    })
}

Circulation()